#pragma once

template<class T = int, int size = 50>
class myQueue_static {
	int front = 0;
	int tail = 0;
public:
	myQueue_static() {}
	~myQueue_static() {}
	T check() {
		if (m_cnt) {
			return m_datas[front];
		}
	}
	bool push(T&& val) {
		if (m_cnt!=size) {
			m_datas[tail]=val;
			if (tail + 1 >= size) {
				tail = 0;
			}
			else ++tail;
			++m_cnt;
			return true;
		}
		return false;
	}
	bool pop() {
		if (!m_cnt) {
			return false;
		}
		if (front + 1 >= size) {
			front = 0;
		}
		else ++front;
		--m_cnt;
		return true;
	}
private:
	T m_datas[size];
	int m_cnt = 0;
};

template<class T = int, int size = 50>
class myDeque_static {
	myDeque_static(){}
	~myDeque_static(){}
	bool push_back(T val) {
		if (m_cnt == size) return false;
		m_datas[r] = val;
		r = r + 1 == size ? 0 : p + 1;
		++m_cnt;
		return true;
	}
	bool push_front(T val) {
		if (m_cnt == size) return false;
		m_datas[l] = val;
		l = l - 1 <0 ? size-1 : l - 1;
		++m_cnt;
		return true;
	}
	bool pop_back(T val) {
		if (m_cnt == 0) return false;
		r = r == 0 ? size-1 : r - 1;
		--m_cnt;
		return true;
	}
	bool pop_front(T val) {
		if (m_cnt == 0) return false;
		l = l == size-1 ? 0 : l + 1;
		--m_cnt;
		return true;
	}
	T front() {
		return m_datas[l==size-1?0:l+1];
	}
	T tail() {
		return m_datas[r == 0 ? size-1 : r-1];
	}
	bool isPULL() { return m_cnt == size; }
	bool isEmpty() { return m_cnt == 0; }
private:
	T m_datas[size];
	int m_cnt = 0;
	int l = 0, r = 0;
};